import 'dart:ffi';

import 'package:json_annotation/json_annotation.dart';

part 'cart_entity.g.dart';

@JsonSerializable()
class CartEntity {
  CartTotalBean? cartTotal;
  List<CartBean>? cartList;

  CartEntity({
    this.cartTotal,
    this.cartList,
  });

  factory CartEntity.fromJson(Map<String, dynamic> json) => _$CartEntityFromJson(json);
  
  Map<String, dynamic> toJson() => _$CartEntityToJson(this);
}

@JsonSerializable()
class CartTotalBean {
  int? goodsCount;
  int? checkedGoodsCount;
  double? goodsAmount; // 使用 dynamic 因为你用 var，类型未知
  double? checkedGoodsAmount;

  CartTotalBean({
    this.goodsCount,
    this.checkedGoodsCount,
    this.goodsAmount,
    this.checkedGoodsAmount,
  });

  factory CartTotalBean.fromJson(Map<String, dynamic> json) => _$CartTotalBeanFromJson(json);
  
  Map<String, dynamic> toJson() => _$CartTotalBeanToJson(this);
}

@JsonSerializable()
class CartBean {
  int? productId;
  String? addTime;
  int? goodsId;
  String? goodsSn;
  String? updateTime;
  int? userId;
  List<String>? specifications;
  int? number;
  String? picUrl;
  bool? deleted;
  double? price;
  bool? checked;
  int? id;
  String? goodsName;

  CartBean({
    this.productId,
    this.addTime,
    this.goodsId,
    this.goodsSn,
    this.updateTime,
    this.userId,
    this.specifications,
    this.number,
    this.picUrl,
    this.deleted,
    this.price,
    this.checked,
    this.id,
    this.goodsName,
  });

  factory CartBean.fromJson(Map<String, dynamic> json) => _$CartBeanFromJson(json);

  Map<String, dynamic> toJson() => _$CartBeanToJson(this);
}